package com.pc.admin.util;

import com.pc.admin.exception.VerifyException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

/**
 * @author langyuanz
 */
@Data
public class PageParam<T> {

    @ApiModelProperty("当前页")
    private Integer current=1;

    @ApiModelProperty("页大小")
    private Integer size=10;

    @ApiModelProperty("请求参数")
    private T param;

    public PageParam(Integer current, Integer size, T param) {
        this.current = current;
        this.size = size;
        this.param = param;
    }

    public void valid() {
        if (Objects.isNull(current) || Objects.isNull(size)) {
            throw new VerifyException("请求分页参数错误");
        }
    }
}
